package com.baosight.risk.service.zbaa.impl;

import com.baosight.risk.api.zbaa.IZbaaTargetGroupService;
import com.baosight.risk.base.service.BaseServiceImpl;
import com.baosight.risk.mapper.zbaa.ZbaaTargetGroupMapper;
import com.baosight.risk.mapper.zbaa.ZbaaTargetGroupOrderMapper;
import com.baosight.risk.service.zbaa.entity.ZbaaTargetGroup;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ZbaaTargetGroupServiceImpl extends BaseServiceImpl<ZbaaTargetGroup> implements IZbaaTargetGroupService {

    @Autowired
    ZbaaTargetGroupMapper zbaaTargetGroupMapper;

    @Autowired
    ZbaaTargetGroupOrderMapper zbaaTargetGroupOrderMapper;

    /**
     * @param id
     * @return
     * @description 根据分组id删除分组以及分组下的订阅信息
     * @author CuiShiHao
     */
    @Override
    public Integer deleteById(String id) {
        zbaaTargetGroupOrderMapper.deleteByGroupID(id);
        return this.delete(id);
    }

    /**
     * @param id
     * @return
     * @description 根据用户id获取用户创建的全部分组
     * @author CuiShiHao
     */
    @Override
    public List<ZbaaTargetGroup> selectGroupByUserId(String id) {
        List<ZbaaTargetGroup> result = zbaaTargetGroupMapper.selectGroupByUserId(id);
        return result;
    }
}
